<!--
 * @Descripttion: 选择班级
 * @Author: wult
 * @Date: 2021-04-06 10:51:55
 * @LastEditTime: 2021-04-12 16:28:32
-->
<template>
  <div class="choose-class">
    <div class="header">
      <div class="el-icon-back" @click="close"></div>
      <div class="tabs_box">
        <div class="title-container">
          <div class="two-line">
            <div></div>
            <div></div>
          </div>
          <div class="title">
            <img src="/src/assets/choose-class/title-icon.png" alt="" />
            <span>请选择上课班级</span>
          </div>
        </div>
      </div>
    </div>
    <div class="class-container" v-if="classList.length > 0">
      <div
        class="class-card"
        v-for="item in classList"
        :key="item.id"
        @click="viewCourse"
      >
        <img
          class="image"
          src="/src/assets/choose-class/class-icon.png"
          alt="班级"
        />
        <div class="class-name">{{ item.title }}</div>
      </div>
    </div>
    <div class="default-container" v-else>
      <div class="default-class-container">
        <div class="default-tips">
          您还未加入任何班级,去联系管理员添加班级吧~
        </div>
        <div class="default-class">
          <div class="default-arrow">
            <div class="tips-icon">
              <div class="tips-icon-yellow"></div>
              <div class="tips-title">使用演示班级上课</div>
            </div>
            <img src="/src/assets/choose-class/right-arrow.png" alt="" />
          </div>
          <div class="class-card" @click="viewCourse">
            <img
              class="image"
              src="/src/assets/choose-class/default-class.png"
              alt=""
            />
            <span class="class-name">演示班级</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { ref, Ref, inject, reactive, toRefs, computed, onMounted } from "vue";
import { ElMessage, ElLoading, ElMessageBox } from "element-plus";
import $, { emitter } from "$";
import axios from "axios";
import ViewCourse from "./view-course.vue";
export default {
  props: {
    id: {
      type: String,
      default: "",
    },
    title: {
      type: String,
      default: "",
    },
  },
  setup(props) {
    let close: any = inject("close");
    let classList = ref([]);
    emitter.on("class-over", () => close());
    const viewCourse = () => {
      $.screen
        .create(
          ViewCourse,
          { id: props.id },
          { zIndex: '2010', hiddenBack: true }
        )
        .then((data: any) => {})
        .catch((data: any) => {});
    };
    const getClassList = async () => {
      const subject: any | null = $.storage.get("subject");
      let res: any = await axios.post<null, { result: boolean; json: any }>(
        "class/queryByUserId",
        { subjectId: subject.code }
      );
      if (res.result) {
        classList.value = res.json;
      }
    };
    getClassList();
    return { close, viewCourse, classList };
  },
};
</script>
<style scoped lang="scss">
.choose-class {
  // background: $--background-color-base;
  background-image: url("/src/assets/choose-class/page-bg.png");
  background-size: 100% 100%;
  height: 100vh;
  overflow: hidden;
  .header {
    // background: #72b22a;33333
    padding: 0 80px;
    display: flex;
    height: 60px;
    line-height: 60px;
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 60px;
    z-index: 10;
    .el-icon-back {
      position: fixed;
      top: 17px;
      left: 30px;
      font-size: 24px;
      color: #fff;
      cursor: pointer;
    }
    .tabs_box {
      flex: auto;
      display: flex;
      justify-content: center;
      align-items: center;
      .two-line {
        display: flex;
        justify-content: space-between;
        padding: 0 96px;
        > div {
          width: 9px;
          height: 42px;
          background: #72b22a;
          box-shadow: 0px -2px 6px 0px rgba(29, 131, 112, 0.7);
        }
      }
      .title-container {
        .title {
          background: #72b22a;
          box-shadow: 0px -2px 6px 0px rgba(29, 131, 112, 0.7);
          border-radius: 35px;
          padding: 5px 96px;
          position: relative;
          font-size: 28px;
          font-family: PingFangSC-Medium, PingFang SC;
          font-weight: 500;
          color: #ffffff;
          > img {
            width: 57px;
            height: 69px;
            position: absolute;
            top: -19px;
            right: -18px;
          }
        }
      }
    }
  }
  .class-container {
    margin-top: 60px;
    height: calc(100vh - 60px);
    padding: 50px 160px;
    display: grid;
    grid-template: auto / repeat(5, 260px);
    grid-column-gap: 1%;
    grid-row-gap: 50px;
    overflow-y: auto;
  }
  .default-container {
    margin-top: 60px;
    padding: 50px 0;
    display: flex;
    justify-content: center;
    .default-class-container {
      background-image: url("/src/assets/choose-class/default-bg.png");
      background-size: 100% 100%;
      padding: 79px 59px;
      .default-tips {
        font-size: 28px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #333333;
        line-height: 40px;
      }
      .default-class {
        margin-top: 80px;
        display: flex;
        justify-content: space-between;
        padding-right: 65px;
        clear: both;
        .default-arrow {
          display: flex;
          align-items: flex-end;
          flex-direction: column;
          .tips-icon {
            position: relative;
            .tips-icon-yellow {
              width: 40px;
              height: 40px;
              background: #f8a608;
              border-radius: 50%;
              position: absolute;
              top: -8px;
              left: -8px;
            }
            .tips-title {
              font-size: 28px;
              font-family: PingFangSC-Semibold, PingFang SC;
              font-weight: 600;
              color: #333333;
              line-height: 40px;
              z-index: 3021;
              position: relative;
              left: 0;
              right: 0;
            }
          }
          > img {
            width: 117px;
            height: 62px;
            margin-top: 49px;
          }
        }
      }
    }
  }
  .class-card {
    background-image: url("/src/assets/choose-class/class-bg.png");
    background-size: 100% 100%;
    // margin-right: 20px;
    width: 190px;
    height: 260px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    cursor: pointer;
    .class-name {
      font-size: 24px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #333333;
      padding: 13px;
      font-size: 14px;
    }
    .image {
      width: 58%;
      height: 42%;
      display: block;
    }
  }
}
</style>
